﻿using NUnit.Framework;

namespace DictionaryExt.Test {

    [TestFixture]
    public class SplitInTokenWith2Entry {

        [Test]
        public void With2Entry() {
            const string s = "a=1;b=2;";
            string[] result = StringExt.StringExt.SplitInToken(s);
            Assert.AreEqual("a=1", result[0]);
            Assert.AreEqual("b=2", result[1]);
        }

        [Test]
        public void MissingSepAtEnd() {
            const string s = "a=1;b=2";
            string[] result = StringExt.StringExt.SplitInToken(s);
            Assert.AreEqual("a=1", result[0]);
            Assert.AreEqual("b=2", result[1]);
        }

        [Test]
        public void Ending2Sep() {
            const string s = "a=1;b=2;;";
            string[] result = StringExt.StringExt.SplitInToken(s);
            Assert.AreEqual("a=1", result[0]);
            Assert.AreEqual("b=2", result[1]);
            Assert.AreEqual(2, result.Length);
        }

        [Test]
        public void Leading2Sep() {
            const string s = ";;a=1;b=2;";
            string[] result = StringExt.StringExt.SplitInToken(s);
            Assert.AreEqual("a=1", result[0]);
            Assert.AreEqual("b=2", result[1]);
            Assert.AreEqual(2, result.Length);
        }

        [Test]
        public void Leading2SepAndMissingSepAtEnd() {
            const string s = ";;a=1;b=2";
            string[] result = StringExt.StringExt.SplitInToken(s);
            Assert.AreEqual("a=1", result[0]);
            Assert.AreEqual("b=2", result[1]);
            Assert.AreEqual(2, result.Length);
        }

        [Test]
        public void InTheMiddle2Sep() {
            const string s = "a=1;;b=2;";
            string[] result = StringExt.StringExt.SplitInToken(s);
            Assert.AreEqual("a=1", result[0]);
            Assert.AreEqual("b=2", result[1]);
            Assert.AreEqual(2, result.Length);
        }

        [Test]
        public void InTheMiddle2SepAndMissingSepAtEnd() {
            const string s = "a=1;;b=2";
            string[] result = StringExt.StringExt.SplitInToken(s);
            Assert.AreEqual("a=1", result[0]);
            Assert.AreEqual("b=2", result[1]);
            Assert.AreEqual(2, result.Length);
        }
    }
}
